<?php
require_once("../../class2.php");
require_once("./includes/require_all.php");
$database->cyr_chars();

$page_class = "PlayON";
$id = (int)$_GET['id'];
$userid = USERID;
$username = USERNAME;

if(USER and ADMIN)
{
	$q = "SELECT * FROM admin_panel WHERE id = {$id}";
	$r = $database->query($q);
	$a = $database->fetch_array($r);
	
	$data = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'."\r\n<game>\r\n";
	
	$q_game_name = $database->query("SELECT distinct file_name FROM {$a['game_prefix']}_text");
	while($a_game_name = $database->fetch_array($q_game_name))
	{
		$game_name = $a_game_name['file_name'];
		$data .= "\t<file name=\"{$game_name}\">\r\n";
		
		$q_text = $database->query("SELECT * FROM {$a['game_prefix']}_text WHERE file_name = '{$game_name}'");
		while($a_text = $database->fetch_array($q_text))
		{
			$bg = htmlspecialchars_decode(trim($a_text['content']));
			$en = htmlspecialchars_decode($a_text['english']);
			
			$data .= "\t\t<languageEn><![CDATA[{$en}]]></languageEn>\r\n\t\t<languageBg><![CDATA[{$bg}]]></languageBg>\r\n";
		}
		
		$data .= "\t</file>\r\n";
	}
	$data .= "</game>";
	
	header("Content-Disposition: attachment; filename={$a['urlprefix']}.xml");
    header('Content-type: text/xml');
	
	echo $data;
}